﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace CNVP.JShop.Web.Admin.CommonWindows
{
    public partial class AjaxNewsInfoProductList : System.Web.UI.Page
    {
        protected string[] productArray;
        protected void Page_Load(object sender, EventArgs e)
        {
            string productLength_Str = Request.QueryString["productLength"];
            String result = Request.QueryString["result"];
            if (!string.IsNullOrEmpty(result))
            {
                string[] resultArray = result.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); 
                productArray = resultArray;
                string AddTr = "";
                int productLength = (!string.IsNullOrEmpty(productLength_Str))
                    ? int.Parse(productLength_Str) : 0;
                if (resultArray.Length > 0)
                {
                    for (int i = 0; i < resultArray.Length; i++)
                    {
                        productLength++;
                        Model.CNVP_Products model = new Model.CNVP_Products();
                        BLL.CNVP_Products bll = new BLL.CNVP_Products();
                        model = bll.GetSingle_CNVP_ProductsById(int.Parse(resultArray[i]));
                        if (model != null)
                        {
                            AddTr += "<tr id=\"tr" + productLength + "\">";
                            AddTr+="<td style=\"width=30px;\">";
                            AddTr += productLength ;
                            AddTr += "</td>";
                            AddTr += "		<td style=\"width:100px;\">";
                            AddTr += "         <a href=\"/ProductDetail_" + model.ProductClassID + "_" + model.ID + ".aspx\" target=\"_blank\" title=\"" + model.ProductName + "\">";
                            AddTr += "		    <img src=\"/UploadFile/Product/" + model.ImgProLoad + "\" class=\"BuyIsPrintPic\"> ";
                            AddTr += "         </a>";
                            AddTr += "      <input type=\"hidden\" id=\"ImgProLoad\" name=\"ImgProLoad\" value=\"" + model.ImgProLoad + "\" />";
                            AddTr += "		</td>";
                            AddTr += "		<td style=\"text-align:left;vertical-align:middle;\">";
                            AddTr += "         <a href=\"/ProductDetail_" + model.ProductClassID + "_" + model.ID + ".aspx\" target=\"_blank\" title=\"" + model.ProductName + "\">";
                            AddTr += "          " + model.ProductName + "";
                            AddTr += "         </a>";
                            AddTr += "      <input type=\"hidden\" id=\"ProductName\" name=\"ProductName\" value=\"" + model.ProductName + "\" />";
                            AddTr += "		</td>";
                            AddTr += "<td style=\"width:200px;vertical-align:middle;\">";
                            AddTr += "<a onclick=\"onMoveUp(this)\"  style=\"cursor:pointer\" productID=\""+ resultArray[i] + "\"> ";
                            AddTr += "向上";
                            AddTr += "</a>";
                            AddTr += "<a onclick=\"onMoveDown(this)\" style=\"cursor:pointer\" productID=\"" + resultArray[i] + "\"> ";
                            AddTr += "向下";
                            AddTr += "</a>";
                            AddTr += "</td>";
                            AddTr += "		<td style=\"width:20px;vertical-align:middle;\">";
                            AddTr += "		<input id=\"BTDel\" type=\"button\" value=\"删除\" onclick='onDelete(this)' />"; 
                            AddTr += "      <input type=\"hidden\" id=\"ProductID\" name=\"ProductID\" value=\"" + resultArray[i] + "\" />";
                            AddTr += "		</td>";
                            AddTr += "	</tr>";
                        }
                    }
                    Response.Write(AddTr);
                }
            }
        }
    }
}